package com.ruowei.modules.sys.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;

import java.io.Serializable;
import java.time.Instant;

import com.ruowei.modules.sys.domain.enumeration.OperateType;

/**
 * 操作日志
 */
@ApiModel(description = "操作日志")
@Entity
@Table(name = "operate_log")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class OperateLog implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 操作人
     */
    @ApiModelProperty(value = "操作人")
    @Column(name = "operator")
    private String operator;

    /**
     * 操作人用户名
     */
    @ApiModelProperty(value = "操作人用户名")
    @Column(name = "operator_login")
    private String operatorLogin;

    /**
     * 被操作主体编码
     */
    @ApiModelProperty(value = "被操作主体编码")
    @Column(name = "jhi_code")
    private String code;

    /**
     * 被操作主体名
     */
    @ApiModelProperty(value = "被操作主体名")
    @Column(name = "jhi_name")
    private String name;

    /**
     * 时间
     */
    @ApiModelProperty(value = "时间")
    @Column(name = "jhi_time")
    private Instant time;

    /**
     * 修改表名
     */
    @ApiModelProperty(value = "修改表名")
    @Column(name = "table_name")
    private String tableName;

    /**
     * 修改字段
     */
    @ApiModelProperty(value = "修改字段")
    @Column(name = "field")
    private String field;

    /**
     * 原值
     */
    @ApiModelProperty(value = "原值")
    @Column(name = "original_value")
    private String originalValue;

    /**
     * 新值
     */
    @ApiModelProperty(value = "新值")
    @Column(name = "new_value")
    private String newValue;

    /**
     * 操作类型
     */
    @ApiModelProperty(value = "操作类型")
    @Enumerated(EnumType.STRING)
    @Column(name = "operate_type")
    private OperateType operateType;

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getOperator() {
        return operator;
    }

    public OperateLog operator(String operator) {
        this.operator = operator;
        return this;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public String getOperatorLogin() {
        return operatorLogin;
    }

    public OperateLog operatorLogin(String operatorLogin) {
        this.operatorLogin = operatorLogin;
        return this;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public OperateLog code(String code) {
        this.code = code;
        return this;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public OperateLog name(String name) {
        this.name = name;
        return this;
    }

    public void setOperatorLogin(String operatorLogin) {
        this.operatorLogin = operatorLogin;
    }

    public Instant getTime() {
        return time;
    }

    public OperateLog time(Instant time) {
        this.time = time;
        return this;
    }

    public void setTime(Instant time) {
        this.time = time;
    }

    public String getTableName() {
        return tableName;
    }

    public OperateLog tableName(String tableName) {
        this.tableName = tableName;
        return this;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getField() {
        return field;
    }

    public OperateLog field(String field) {
        this.field = field;
        return this;
    }

    public void setField(String field) {
        this.field = field;
    }

    public String getOriginalValue() {
        return originalValue;
    }

    public OperateLog originalValue(String originalValue) {
        this.originalValue = originalValue;
        return this;
    }

    public void setOriginalValue(String originalValue) {
        this.originalValue = originalValue;
    }

    public String getNewValue() {
        return newValue;
    }

    public OperateLog newValue(String newValue) {
        this.newValue = newValue;
        return this;
    }

    public void setNewValue(String newValue) {
        this.newValue = newValue;
    }

    public OperateType getOperateType() {
        return operateType;
    }

    public OperateLog operateType(OperateType operateType) {
        this.operateType = operateType;
        return this;
    }

    public void setOperateType(OperateType operateType) {
        this.operateType = operateType;
    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof OperateLog)) {
            return false;
        }
        return id != null && id.equals(((OperateLog) o).id);
    }

    @Override
    public int hashCode() {
        return 31;
    }

    @Override
    public String toString() {
        return "OperateLog{" +
            "id=" + getId() +
            ", operator='" + getOperator() + "'" +
            ", operatorLogin='" + getOperatorLogin() + "'" +
            ", time='" + getTime() + "'" +
            ", tableName='" + getTableName() + "'" +
            ", field='" + getField() + "'" +
            ", originalValue='" + getOriginalValue() + "'" +
            ", newValue='" + getNewValue() + "'" +
            ", operateType='" + getOperateType() + "'" +
            "}";
    }
}
